package org.jeecg.modules.nongjt.user.controller;


import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;

import org.jeecg.modules.nongjt.user.entity.NjtUserPerfect;
import org.jeecg.modules.nongjt.user.service.INjtUserPerfectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户完善信息 前端控制器
 * </p>
 *
 * @author tianshao
 * @since 2022-06-15
 */
@RestController
@RequestMapping("/njt-user-perfect")
public class NjtUserPerfectController {
    @Autowired
    private INjtUserPerfectService iNjtUserPerfectService;
    @GetMapping("/page")
    public Result<?> selectByPage(@RequestParam(defaultValue = "1")int current,
                                  @RequestParam(defaultValue = "3")int pageSize,
                                  NjtUserPerfect njtUserPerfect){
        System.out.println(njtUserPerfect);
        QueryWrapper<NjtUserPerfect> njtUserRegisterQueryWrapper = new QueryWrapper<>();
        Page<NjtUserPerfect> page = new Page<>(current, pageSize);
        if (njtUserPerfect!=null)
        {
            if (!StringUtils.isEmpty(njtUserPerfect.getCompanyName()))
            {
                njtUserRegisterQueryWrapper.like("company_name",njtUserPerfect.getCompanyName());
            }

        }
        if (njtUserPerfect!=null)
        {
            if (!StringUtils.isEmpty(njtUserPerfect.getMobilePhone()))
            {
                njtUserRegisterQueryWrapper.eq("mobile_phone",njtUserPerfect.getMobilePhone());
            }

        }
        iNjtUserPerfectService.page(page, njtUserRegisterQueryWrapper);
        System.out.println(page);
        return Result.OK(page);
    }

}

